package com.junsi.service.impl;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.junsi.bean.Operate;
import com.junsi.bean.Staff;
import com.junsi.mapper.OperateMapper;

import com.junsi.service.OperateService;
import com.junsi.util.PageUtil;


/**   
  * @文件名: SaleServiceImpl.java 
  * @包名: com.junsi.service.impl 
  * @类名: SaleServiceImpl   
  * @时间: 2017年6月28日 上午9:21:00 2017
  * @作者: 
  * @类功能描述:TODO 请简要描述你的类   
  */
@Service
@Transactional(rollbackFor = Exception.class)
public class OperateServiceImpl implements OperateService {
	
	@Autowired
	private OperateMapper operateMapper;

	@Override
	public boolean insert(Operate operate) throws Exception {
		int result = operateMapper.insert(operate);
		if(result == 1){
			return true;
		}else {
			return false;
		}
	}

	@Override
	public boolean delete(Integer id) {
		int result = operateMapper.delete(id);
		if(result == 1){
			return true;
		}else {
			return false;
		}
	}

	@Override
	public boolean update(Operate operate) throws Exception{
		int result = operateMapper.update(operate);
		if(result == 1){
			return true;
		}else {
			return false;
		}
	}

	@Override
	public List<Operate> listAll() {
		return operateMapper.listAll();
	}

	@Override
	public Operate findById(Integer id) {
		return operateMapper.findById(id);
	}

	public List<Operate> pageFind(String[] id,Integer endIndex,Integer startIndex) {
		if(endIndex == null){
			return null;
		}
		if(startIndex == null){
			return null;
		}
		
		return operateMapper.pageFind(id,endIndex, startIndex);
	}

	public int findCount(String[] id) {
		return operateMapper.findCount(id);
	}
	public List<Operate> findByName(String name,Integer opid,String leixing,String[] id,Integer endIndex,Integer startIndex) {
		name = "%"+name+"%";
		leixing = "%"+leixing+"%";
		return operateMapper.findByName(name,opid,leixing,id,endIndex,startIndex);
	}

	@Override
	public List<Operate> findByhoutaiName(String name, Integer endIndex, Integer startIndex) {
		name = "%"+name+"%";
		return operateMapper.findByhoutaiName(name, endIndex, startIndex);
	}

	@Override
	public int findCountCondition(String condition) {
		 int count=operateMapper.findCountCondition(condition);
		  return count;
	}

	@Override
	public List<Operate> findByhoutaiNameCondition(String condition, PageUtil pageUtil) {
		List<Operate> page=operateMapper.findByhoutaiNameCondition(condition,pageUtil.getEndIndex(), pageUtil.getBeginIndex());
		return page;
	}

	@Override
	public int findCountConditionTwo(String condition) {
		 int count=operateMapper.findCountConditionTwo(condition);
		  return count;
	}

	@Override
	public List<Operate> findByNameTwo(String condition, PageUtil pageUtil) {
		List<Operate> page=operateMapper.findByNameTwo(condition,pageUtil.getEndIndex(), pageUtil.getBeginIndex());
		return page;
	}
	
}
